package com.guoxin.thread.pool;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class CachedThreadPool {

    public static void main(String[] args) {
        ExecutorService executorService = Executors.newCachedThreadPool();
        for(int i=0;i<10;i++){
            int index = i;
            executorService.execute(() -> {
                System.out.println(Thread.currentThread()+"---"+index);
                if(index==9){
                    executorService.shutdown();
                }
            });
        }
    }
}
